﻿#pragma once


#include <QDialog>
#include <QPushButton>
#include "QListView"
#include "QStringListModel"
#include "QFileDialog"
#include "QMessageBox"
#include "QApplication"
#include "QVBoxLayout"
#include <QDesktopWidget>
#include <QLibrary>
#include <QApplication>
#include <QLabel>
#include <QComboBox>
#include "QListView"
#include "QStringListModel"
#include "QLineEdit"
#include "QSpinBox"
#include <QSettings>

#include "commonfunction.h"

#include "halcon_opencv.h"

using namespace std;

#include "qt_graphics_view_image.h"
#include "qt_graphics_shape_rectangle.h"





//#include <fstream>
//#include "nlohmann/json.hpp"
//using json = nlohmann::json;
//QSettings* m_qsettings;

class FunctionDump :public QDialog
{
public:
    QSettings* m_qsettings;
    Mat m_image ,m_image_show;
    QString m_section   = "";

    MyQGraphicsView* m_view ;



    QLabel* m_qlabel_row1;
    QSpinBox* m_qspinbox_row1;

    QLabel* m_qlabel_row2;
    QSpinBox* m_qspinbox_row2;

    QLabel* m_qlabel_column1;
    QSpinBox* m_qspinbox_column1;

    QLabel* m_qlabel_column2;
    QSpinBox* m_qspinbox_column2;




    /*QLabel* m_qlabel_space;
    QSpinBox* m_qspinbox_space;*/
    int m_space=10;

    /*QLabel* m_qlabel_position;
    QComboBox* m_qcombox_position;*/
    int m_positon;

    /*QLabel* m_qlabel_transition;
    QComboBox* m_qcombox_transition;*/
    int m_transition;

	/*QLabel* m_qlabel_detection_count;
    QSpinBox* m_qspinbox_detection_count;*/
	int m_detection_count = 1;

    /*QLabel* m_qlabel_edge_threshold;
    QSpinBox* m_qspinbox_edge_threshold;*/
    int m_edge_threshold= 25;

	QLabel * m_qlabel_standard_left_min;
	QSpinBox * m_qspinbox_standard_left_min;
	int m_standard_left_min = 0;

    QLabel * m_qlabel_standard_left_max;
    QSpinBox * m_qspinbox_standard_left_max;
    int m_standard_left_max = 0;

	QLabel* m_qlabel_standard_right_min;
	QSpinBox* m_qspinbox_standard_right_min;
	int m_standard_right_min = 0;

    QLabel* m_qlabel_standard_right_max;
    QSpinBox* m_qspinbox_standard_right_max;
    int m_standard_right_max=0;



	QPushButton* m_pushbutton_show_orign_image;
    QPushButton* m_pushbutton_detection;
    QPushButton* m_pushbutton_save_parameter;
    QPushButton* m_pushbutton_return;

    QLabel* m_qlabel_message;

    int m_result;




    HObject m_region_error, m_region_line,m_region_cross;

	double value_standard=0;

    HObject image_in;
    int Row1, Column1, Row2, Column2;

    

public:
    explicit FunctionDump(QDialog *parent = nullptr, QSettings* qsettings = nullptr,QString section="") ;
    ~FunctionDump() ;
    virtual void detectionImage();
    virtual bool detection( HObject image_in, QString& message);
    virtual void draw( Mat image_in,Mat& image_out);
    virtual void loadParameter();
    virtual void saveParameter();
    virtual bool showDialog();
};
#pragma execution_character_set("utf-8")
